
//var diimoClickCookie=readDiimoCookie('diimoProductClicked');
   	
var isIE8 = window.XDomainRequest ? true : false;
var invocation = createDiimoCrossDomainRequest();
// var url = 'http://localhost/clothingforus/index.php/cpaActionVerification/CpaEvent'; 
var url = 'http://www.demot.diimosolutions.com/clothingforus/index.php/cpaActionVerification/CpaEvent'; 

// var url = 'http://www.demot.diimosolutions.com/clothingforus/index.php/cpaActionVerification/CpaEvent'; 

//if(diimoClickCookie!=null){
//
//   		callDiimoDomain();
//   			
//}

function createDiimoCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readDiimoCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseDiimoCookie(name) {
	createCookie(name,"",-1);
}
       

function createDiimoCrossDomainRequest(url, diimoHandler)
{
    var request;
    if (isIE8)
    {
        request = new window.XDomainRequest();
    }
    else
    {
        request = new XMLHttpRequest();
    }
    return request;
}

function callDiimoDomain(requestValues)
{
    if (invocation)
    {
    	
        if(isIE8)
        {
            invocation.onload = outputResult;
            invocation.open("GET", url+"?keyValues="+requestValues, true);
            invocation.send();
        }
        else
        {
            invocation.open('GET', url+"?keyValues="+requestValues, true);
            invocation.onreadystatechange = diimoHandler;
            invocation.send();
        }
        
    }
    else
    {
        var text = "No Invocation TookPlace At All";
        var textNode = document.createTextNode(text);
        var textDiv = document.getElementById("textDiv");
        textDiv.appendChild(textNode);
    }
}

 
function diimoHandler(evtXHR)
{
    if (invocation.readyState == 4)
    {
        if (invocation.status == 200)
        {
            diimoOutputResult();
        }
        else
        {
            alert("Invocation Errors Occured");
        }
    }
}

function diimoOutputResult()
{
    var response = invocation.responseText;
    var textDiv = document.getElementById("textDiv");
    textDiv.innerHTML += response;
}

 
